{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "9651c25a-42b7-4208-8445-f5546f907a45",
   "metadata": {},
   "source": [
    "# 第二节、数据查看"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "8b77b647-3734-43f7-b22e-559255231273",
   "metadata": {},
   "source": [
    "查看DataFrame的常用属性和DataFrame的概览和统计信息。"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "9eaa9ed5-3736-4016-8a7f-1eeeeb759d49",
   "metadata": {},
   "source": [
    "## （1）查看属性"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "58a55e01-f831-4f20-91dd-002283169463",
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "d3af6c13-3939-449d-abd8-a9baf3143738",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>94</td>\n",
       "      <td>55</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>7</td>\n",
       "      <td>16</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>75</td>\n",
       "      <td>99</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>24</td>\n",
       "      <td>43</td>\n",
       "      <td>148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>77</td>\n",
       "      <td>41</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>...</th>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "      <td>...</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>119</td>\n",
       "      <td>115</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>114</td>\n",
       "      <td>28</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>75</td>\n",
       "      <td>126</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>141</td>\n",
       "      <td>65</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>126</td>\n",
       "      <td>49</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "<p>150 rows × 3 columns</p>\n",
       "</div>"
      ],
      "text/plain": [
       "     python  math  english\n",
       "0        94    55       52\n",
       "1         7    16       27\n",
       "2        75    99       21\n",
       "3        24    43      148\n",
       "4        77    41      115\n",
       "..      ...   ...      ...\n",
       "145     119   115       56\n",
       "146     114    28      101\n",
       "147      75   126       97\n",
       "148     141    65      149\n",
       "149     126    49       16\n",
       "\n",
       "[150 rows x 3 columns]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建 shape(150, 3) 的二维标签数组结构 DataFrame\n",
    "df = pd.DataFrame(\n",
    "    data=np.random.randint(0, 150, size=(150, 3)),\n",
    "    columns=['python', 'math', 'english']\n",
    ")\n",
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "b90c2ad9-5771-4daa-9389-02f40795255d",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>94</td>\n",
       "      <td>55</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>7</td>\n",
       "      <td>16</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>75</td>\n",
       "      <td>99</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>24</td>\n",
       "      <td>43</td>\n",
       "      <td>148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>77</td>\n",
       "      <td>41</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   python  math  english\n",
       "0      94    55       52\n",
       "1       7    16       27\n",
       "2      75    99       21\n",
       "3      24    43      148\n",
       "4      77    41      115"
      ]
     },
     "execution_count": 5,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看属性、概览和统计信息\n",
    "df.head()   # 默认显示5个"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "28aa663b-294e-4b43-93d1-0f2360a1d696",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>94</td>\n",
       "      <td>55</td>\n",
       "      <td>52</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>7</td>\n",
       "      <td>16</td>\n",
       "      <td>27</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>75</td>\n",
       "      <td>99</td>\n",
       "      <td>21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>24</td>\n",
       "      <td>43</td>\n",
       "      <td>148</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>77</td>\n",
       "      <td>41</td>\n",
       "      <td>115</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>114</td>\n",
       "      <td>129</td>\n",
       "      <td>49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>104</td>\n",
       "      <td>104</td>\n",
       "      <td>135</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>1</td>\n",
       "      <td>75</td>\n",
       "      <td>105</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>14</td>\n",
       "      <td>72</td>\n",
       "      <td>140</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>140</td>\n",
       "      <td>127</td>\n",
       "      <td>11</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   python  math  english\n",
       "0      94    55       52\n",
       "1       7    16       27\n",
       "2      75    99       21\n",
       "3      24    43      148\n",
       "4      77    41      115\n",
       "5     114   129       49\n",
       "6     104   104      135\n",
       "7       1    75      105\n",
       "8      14    72      140\n",
       "9     140   127       11"
      ]
     },
     "execution_count": 6,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.head(10)  # 指定个数字就查询多少行"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "0660a4e1-0681-4005-ab0d-a4c27f5645a2",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>145</th>\n",
       "      <td>119</td>\n",
       "      <td>115</td>\n",
       "      <td>56</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>146</th>\n",
       "      <td>114</td>\n",
       "      <td>28</td>\n",
       "      <td>101</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>147</th>\n",
       "      <td>75</td>\n",
       "      <td>126</td>\n",
       "      <td>97</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>148</th>\n",
       "      <td>141</td>\n",
       "      <td>65</td>\n",
       "      <td>149</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>149</th>\n",
       "      <td>126</td>\n",
       "      <td>49</td>\n",
       "      <td>16</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "     python  math  english\n",
       "145     119   115       56\n",
       "146     114    28      101\n",
       "147      75   126       97\n",
       "148     141    65      149\n",
       "149     126    49       16"
      ]
     },
     "execution_count": 7,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.tail()  # 从尾部开始查，和head同理"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "e70f9035-c28a-4725-b9a9-a2185edac812",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "(150, 3)"
      ]
     },
     "execution_count": 8,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.shape   # 查看形状，行数和列数"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "id": "61f2c291-3e17-4f9f-aaf8-11607379c9d5",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "python     int32\n",
       "math       int32\n",
       "english    int32\n",
       "dtype: object"
      ]
     },
     "execution_count": 10,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.dtypes  # 查看数据类型，一定注意最后有个s"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "id": "3062002d-8b93-4459-8ce5-32b877d14ca1",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "RangeIndex(start=0, stop=150, step=1)"
      ]
     },
     "execution_count": 12,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.index   # 行索引，返回的是一个行索引对象"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "id": "ee3f2d9e-2353-4c13-a4b6-45a8a8ea30cd",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "Index(['python', 'math', 'english'], dtype='object')"
      ]
     },
     "execution_count": 13,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.columns  # 列索引"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "id": "382da412-fe52-4f0a-be73-dd22a3f9947c",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([[ 94,  55,  52],\n",
       "       [  7,  16,  27],\n",
       "       [ 75,  99,  21],\n",
       "       [ 24,  43, 148],\n",
       "       [ 77,  41, 115],\n",
       "       [114, 129,  49],\n",
       "       [104, 104, 135],\n",
       "       [  1,  75, 105],\n",
       "       [ 14,  72, 140],\n",
       "       [140, 127,  11],\n",
       "       [135,  61,  34],\n",
       "       [116,  69,  53],\n",
       "       [ 30,  68, 144],\n",
       "       [ 24,  36,  18],\n",
       "       [110,  96,  86],\n",
       "       [149,  74, 137],\n",
       "       [ 34,  45,  40],\n",
       "       [106,  36,  58],\n",
       "       [ 71, 119, 136],\n",
       "       [130, 102,  78],\n",
       "       [127,  37,  58],\n",
       "       [ 62,   9,  30],\n",
       "       [132,  85,  47],\n",
       "       [107,  78, 143],\n",
       "       [133,  67,  43],\n",
       "       [119,  52, 135],\n",
       "       [ 57, 101,  72],\n",
       "       [ 59,  28, 121],\n",
       "       [ 32,  63,  52],\n",
       "       [122, 131, 124],\n",
       "       [ 41,  15,  29],\n",
       "       [113,  20,  33],\n",
       "       [ 23, 112,  84],\n",
       "       [135,  44,  51],\n",
       "       [  9,  51,  42],\n",
       "       [ 28,  89,  88],\n",
       "       [ 10, 102, 140],\n",
       "       [ 82, 147,  45],\n",
       "       [ 61,  48, 117],\n",
       "       [131,  50,  15],\n",
       "       [122,  69,  96],\n",
       "       [ 92, 114,  46],\n",
       "       [ 46, 148,   4],\n",
       "       [ 68,  24,  84],\n",
       "       [ 10,  71, 102],\n",
       "       [ 61,  84, 135],\n",
       "       [ 54,  52,  50],\n",
       "       [130, 127, 148],\n",
       "       [ 94, 114,  35],\n",
       "       [ 28, 124,  32],\n",
       "       [ 46,   2,  90],\n",
       "       [141, 123,  85],\n",
       "       [128,   6,  44],\n",
       "       [ 83,  55,  56],\n",
       "       [ 39,   7,  70],\n",
       "       [105,  46,  87],\n",
       "       [111, 134, 113],\n",
       "       [ 80,  49,  43],\n",
       "       [ 95, 104, 137],\n",
       "       [129, 128,   7],\n",
       "       [ 54,  83,  27],\n",
       "       [ 16,  54,  40],\n",
       "       [ 74,  87,  77],\n",
       "       [129,  76, 127],\n",
       "       [ 70, 135,  46],\n",
       "       [ 62,   2,  42],\n",
       "       [ 22,  32, 109],\n",
       "       [ 62,  18, 123],\n",
       "       [ 44, 112, 104],\n",
       "       [ 73,  94, 100],\n",
       "       [ 15, 117, 146],\n",
       "       [ 25,  13,  40],\n",
       "       [  0, 140, 102],\n",
       "       [127, 134,  13],\n",
       "       [ 21, 103,  99],\n",
       "       [141,  40,  77],\n",
       "       [ 79, 104,  90],\n",
       "       [145, 121,  59],\n",
       "       [ 80, 144,  61],\n",
       "       [104,  13,  88],\n",
       "       [107,  64,  46],\n",
       "       [124,  68, 103],\n",
       "       [147,  10, 146],\n",
       "       [ 81,  89,   3],\n",
       "       [143,  72,  91],\n",
       "       [ 24, 134,  38],\n",
       "       [ 97, 116, 115],\n",
       "       [ 58, 138,  62],\n",
       "       [ 59,  37,  59],\n",
       "       [ 39,  28,  15],\n",
       "       [ 10, 108, 126],\n",
       "       [ 14,  42,  92],\n",
       "       [106,  53,  46],\n",
       "       [ 79, 126,  70],\n",
       "       [ 95,  71,  46],\n",
       "       [ 54,  19, 142],\n",
       "       [ 94, 100,  13],\n",
       "       [ 39,  68,  37],\n",
       "       [ 43,   9, 101],\n",
       "       [ 72, 115,  91],\n",
       "       [128,   2,  42],\n",
       "       [  3,   7,  40],\n",
       "       [ 59,  86,  48],\n",
       "       [ 48,  29,  70],\n",
       "       [ 90, 118,  42],\n",
       "       [ 19,  68, 118],\n",
       "       [ 97,  43,  73],\n",
       "       [ 46,  28,  55],\n",
       "       [ 89,  37, 138],\n",
       "       [145, 128,  37],\n",
       "       [ 80, 105, 112],\n",
       "       [ 88, 146,  46],\n",
       "       [133, 125, 118],\n",
       "       [ 87,  15, 145],\n",
       "       [149, 147, 133],\n",
       "       [104,  36,  30],\n",
       "       [ 82, 133,   0],\n",
       "       [ 23,  46, 141],\n",
       "       [ 74, 132,  94],\n",
       "       [ 14,  18, 127],\n",
       "       [117,  88, 144],\n",
       "       [ 66,   6,  68],\n",
       "       [ 86,  98,  58],\n",
       "       [119,  70,  45],\n",
       "       [ 85,  55,  67],\n",
       "       [136, 104,  37],\n",
       "       [ 33, 149, 130],\n",
       "       [ 30,  52,  79],\n",
       "       [ 77,  65, 127],\n",
       "       [ 23,  68,  15],\n",
       "       [ 42,  85, 102],\n",
       "       [ 96,  72,  48],\n",
       "       [145,   5,  34],\n",
       "       [ 31, 111,  54],\n",
       "       [ 50,  71, 143],\n",
       "       [121,  21,  48],\n",
       "       [123, 110, 111],\n",
       "       [116,  28,  85],\n",
       "       [115,  97,  72],\n",
       "       [ 44,  40, 102],\n",
       "       [141, 122,   0],\n",
       "       [ 40,  74,  83],\n",
       "       [ 55,  56,  41],\n",
       "       [ 70, 139,  54],\n",
       "       [147,  60,  31],\n",
       "       [119, 115,  56],\n",
       "       [114,  28, 101],\n",
       "       [ 75, 126,  97],\n",
       "       [141,  65, 149],\n",
       "       [126,  49,  16]])"
      ]
     },
     "execution_count": 14,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.values   # DataFrame里面存放的数据，返回的是一个ndarray"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "7b089af7-5382-4f12-8c66-f955c07d0308",
   "metadata": {},
   "source": [
    "## （2）查看概述与统计信息"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "id": "bad09934-2d3b-4933-8be8-7bd5271006b3",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>python</th>\n",
       "      <th>math</th>\n",
       "      <th>english</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>count</th>\n",
       "      <td>150.000000</td>\n",
       "      <td>150.000000</td>\n",
       "      <td>150.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>mean</th>\n",
       "      <td>79.126667</td>\n",
       "      <td>74.293333</td>\n",
       "      <td>75.586667</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>std</th>\n",
       "      <td>42.557233</td>\n",
       "      <td>41.845761</td>\n",
       "      <td>41.666652</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>min</th>\n",
       "      <td>0.000000</td>\n",
       "      <td>2.000000</td>\n",
       "      <td>0.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25%</th>\n",
       "      <td>43.250000</td>\n",
       "      <td>41.250000</td>\n",
       "      <td>42.250000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>50%</th>\n",
       "      <td>80.000000</td>\n",
       "      <td>71.000000</td>\n",
       "      <td>70.000000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>75%</th>\n",
       "      <td>116.750000</td>\n",
       "      <td>111.750000</td>\n",
       "      <td>110.500000</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>max</th>\n",
       "      <td>149.000000</td>\n",
       "      <td>149.000000</td>\n",
       "      <td>149.000000</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           python        math     english\n",
       "count  150.000000  150.000000  150.000000\n",
       "mean    79.126667   74.293333   75.586667\n",
       "std     42.557233   41.845761   41.666652\n",
       "min      0.000000    2.000000    0.000000\n",
       "25%     43.250000   41.250000   42.250000\n",
       "50%     80.000000   71.000000   70.000000\n",
       "75%    116.750000  111.750000  110.500000\n",
       "max    149.000000  149.000000  149.000000"
      ]
     },
     "execution_count": 15,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 查看数值型列的汇总、统计、计数、平均值、标准差、最小值、四分位数、最大值\n",
    "df.describe()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "id": "2b4f9855-a97e-4b15-b96e-5c87a1897f43",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "RangeIndex: 150 entries, 0 to 149\n",
      "Data columns (total 3 columns):\n",
      " #   Column   Non-Null Count  Dtype\n",
      "---  ------   --------------  -----\n",
      " 0   python   150 non-null    int32\n",
      " 1   math     150 non-null    int32\n",
      " 2   english  150 non-null    int32\n",
      "dtypes: int32(3)\n",
      "memory usage: 1.9 KB\n"
     ]
    }
   ],
   "source": [
    "# 查看列索引，数据类型，非空计数和内存信息\n",
    "df.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7ba4011-61f9-4e95-8827-743acd7b10fb",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.10.11"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
